package com.euro.video.phone.utils;

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

public class ImageUtil {
	private byte[] image;
	private static ImageUtil instance;

	private ImageUtil() {
	}

	public static ImageUtil getSingleInstace() {
		if (instance == null) {
			instance = new ImageUtil();
		}

		return instance;
	}

	public static Dimension getImageSize(byte[] image) throws IOException {
		if (image == null) {
			return new Dimension(0, 0);
		}

		InputStream in = new ByteArrayInputStream(image);
		BufferedImage buf = ImageIO.read(in);
		return new Dimension(buf.getWidth(), buf.getHeight());
	}

	public byte[] getImage() {
		return image;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}
}
